﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Text;

namespace Xiaov.SmartWeb.Application.PluginSrc.StatisticalSystem.ReportDesign
{
  public partial class ExcelExport : System.Web.UI.Page
  {
    protected void Page_Load(object sender, EventArgs e)
    {
      string dwbm = Request.QueryString["dwbm"].ToString();
      string nf = Request.QueryString["year"].ToString();
      string bbbms = Request.QueryString["bbbm"].ToString();
      bbbms = bbbms.Substring(0, bbbms.Length - 1);
      string yf = Request.QueryString["month"].ToString();
      StringBuilder xml = new StringBuilder();
      xml.Clear();
      System.Web.HttpContext.Current.Response.Clear();
      System.Web.HttpContext.Current.Response.Buffer = true;
      System.Web.HttpContext.Current.Response.ContentEncoding = Encoding.GetEncoding("utf-8");
      System.Web.HttpContext.Current.Response.Charset = "";
      System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment; filename=" + dwbm + "_" + nf + "_" + yf + ".xls");
      System.Web.HttpContext.Current.Response.ContentType = "text/xml";
      Excel.ExportExcel excel = new Excel.ExportExcel();
      xml.Append(excel.GetXML(dwbm, bbbms, nf, yf));
      System.Web.HttpContext.Current.Response.Write(xml.ToString());
      System.Web.HttpContext.Current.Response.End();

    }

    private string GetDWMC(string dwbm)
    {
      string sql = "select dwmc from dwbmb where dwbm='" + dwbm + "'";
      string dwmc = Maticsoft.DBUtility.DbHelperOra.GetSingle(sql).ToString();
      return dwmc;
    }
  }
}